/*
package com.xhui.reggie.filter;

import com.alibaba.fastjson.JSON;
import com.xhui.reggie.common.BaseContext;
import com.xhui.reggie.common.R;
import org.springframework.util.AntPathMatcher;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;


@WebFilter(filterName = "myCheckFilter", urlPatterns = "/*")
public class MyCheckFilter implements Filter {

    // 配置一个蚂蚁路径匹配器
    private static final AntPathMatcher PATH_MATCHER = new AntPathMatcher();

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        HttpServletResponse response = (HttpServletResponse) servletResponse;


        // 前后台均可访问的urls
        String[] commonUrls = new String[]{
                "/front/page/login.html",
                "/backend/page/login/login.html",
                "/user/login",
                "/user/sendMsg",
                "/employee/login",
        };

        // 前台可访问的urls
        String[] frontUrls = new String[]{
                "/front/**", // 前台的静态资源
                //"/addressBook/**"
        };
        // 后台的可访问的urls
        String[] backUrls = new String[]{
                "/backend/**", // 后台的静态资源
               // "/addressBook/**",
        };
        String requestURI = request.getRequestURI();
        boolean commonFlag = checkUrls(frontUrls, requestURI);
        boolean frontFlag = checkUrls(frontUrls, requestURI);
        boolean backFlag = checkUrls(backUrls, requestURI);

        HttpSession session = request.getSession();
        Object user = session.getAttribute("user");
        Object employee = session.getAttribute("employee");


        if(commonFlag){
            filterChain.doFilter(request, response);
            return ;
        }

        if(user != null && frontFlag){
            Long userId = (Long) session.getAttribute("user");
            BaseContext.setCurrentId(userId);
            filterChain.doFilter(request, response);
            return;
        }

        if(employee != null && backFlag){
            Long empId = (Long) session.getAttribute("employee");
            BaseContext.setCurrentId(empId);
            filterChain.doFilter(request, response);
            return;
        }

        response.getWriter().write(JSON.toJSONString(R.error("NOTLOGIN")));;


    }


    public static boolean checkUrls(String[] urls, String url) {
        for (String pattern : urls) {
            if (PATH_MATCHER.match(pattern, url)) {
                return true;
            }
        }
        return false;
    }
}
*/
